(GH-1529) Add whatIf support for SSHD config resources#1586
Open
Gijsreyn wants to merge 1 commit into
Open
Conversation
81cb475 to
9363b57
Compare
9363b57 to
dfc95ce
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds --what-if support for the built-in OpenSSH SSHD config resources by wiring a new --what-if flag through the sshdconfig CLI, updating resource manifests to advertise what-if support, and adding Pester coverage to validate both manifest metadata and non-mutating what-if behavior.
Changes:
- Add a
--what-ifflag tosshdconfig setand plumb it into set handlers to return predicted state without applying changes. - Update SSHD-related resource manifests to include
whatIfArgandwhatIfReturns. - Add Pester tests validating manifest what-if declarations and verifying no file/registry writes during what-if runs.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/sshdconfig/tests/sshdconfig.whatif.tests.ps1 | Adds Pester coverage for manifest what-if metadata and what-if “no side effects” behavior. |
| resources/sshdconfig/sshd-windows.dsc.resource.json | Declares what-if support for the Windows global SSHD settings resource. |
| resources/sshdconfig/sshd-subsystemList.dsc.resource.json | Declares what-if support for the SubsystemList resource. |
| resources/sshdconfig/sshd-subsystem.dsc.resource.json | Declares what-if support for the Subsystem resource. |
| resources/sshdconfig/sshd_config.dsc.resource.json | Declares what-if support for the sshd_config resource. |
| resources/sshdconfig/src/set.rs | Implements what-if behavior in set paths and returns predicted state when requested. |
| resources/sshdconfig/src/main.rs | Wires the what_if flag from CLI parsing into invoke_set. |
| resources/sshdconfig/src/args.rs | Adds --what-if/-w flag to the set subcommand. |
| resources/sshdconfig/locales/en-us.toml | Adds localized help text for the new what-if flag. |
Comments suppressed due to low confidence (1)
resources/sshdconfig/src/set.rs:107
- In
--what-ifmode,get_existing_config(cmd_info)?can indirectly seed/copy a defaultsshd_configviaensure_sshd_config_exists(...)(seeget_existing_configimplementation). That would be a side effect during what-if for repeat-keyword operations when the target config file doesn’t exist yet.
let (keyword, entry_value) = extract_single_keyword(keyword_input.additional_properties)?;
let mut existing_config = get_existing_config(cmd_info)?;
Comment on lines
+78
to
+82
| let desired_state = get_default_shell_desired_state(default_shell)?; | ||
| if what_if { | ||
| default_shell_to_map(&desired_state) | ||
| } else { | ||
| set_default_shell(&desired_state)?; |
Comment on lines
142
to
145
|
|
||
| let (keyword, entries_value) = extract_single_keyword(list_input.additional_properties)?; | ||
| let mut existing_config = get_existing_config(cmd_info)?; | ||
| // Ensure it's an array |
Comment on lines
+298
to
+302
| write_and_validate_config( | ||
| &mut config_to_write, | ||
| cmd_info.metadata.filepath.as_ref(), | ||
| what_if, | ||
| )?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Add whatIf support for SSHD config resources.
PR Context
Partially addresses #1529.